package com.tigase.controller;

import com.tigase.config.MyException;
import com.tigase.dao.TigaseUserMapper;
import com.tigase.service.UserService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;


/**
 * Created by Mer on 2017/7/6.
 */
@Controller
@RequestMapping("/HelloController")
public class HelloController {
    private Logger logger = Logger.getLogger(HelloController.class);
    @Autowired
    private UserService userSerivce;
    private TigaseUserMapper TigaseUser;

    private com.tigase.MongoServiceImpl.UserServiceRepository UserServiceRepository;
    @RequestMapping(value = "/hellos", method = RequestMethod.GET)
    @ResponseBody
    public Map<String, Object> hellos() {
            System.out.print("dddddddddd");
        Map<String ,Object> map=new HashMap<>();
        TigaseUser.selectByPrimaryKey("1");
        map.put("msg","数据查询成功");
        map.put("flag",true);

         return map;
    }

    @RequestMapping("/hello")
    public String hello() throws Exception {
        throw new Exception("发生错误");
    }

    @RequestMapping("/json")
    public String json() throws MyException {

        throw new MyException("发生错误2");
    }

    @RequestMapping("/")
    public String index(ModelMap map) {
        logger.info("输出info");
        logger.debug("输出debug");
        logger.error("输出error");
        map.addAttribute("host", "http://blog.didispace.com");
        return "index";
    }

//    @RequestMapping(value = "/test", method = RequestMethod.GET)
//    @ResponseBody
//    public String tests() throws Exception {
//        List<Users> b= UserServiceRepository.test();
//        return "Hello " + b;
//    }


}
